<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title> new document </title>
  <link rel="stylesheet" type="text/css" href="../js/resources/css/ext-all.css" />
  <script type="text/javascript" src="../js/adapter/ext/ext-base.js"></script>
  <script type="text/javascript" src="../js/ext-all.js"></script>
  <script type="text/javascript">
/*	Ext.onReady(function(){ 
	var sm = new Ext.grid.CheckboxSelectionModel(); 
	var tempCM = new Ext.grid.ColumnModel([
	  new Ext.grid.RowNumberer(),
	  sm,{
	   header : "公司名称",
	   width : 300,
	   dataIndex : "deptName",
	   align : "left",
	   menuDisabled : true
	  }, {
	   header : "地址",
	   width : 400,
	   dataIndex : "address",
	   align : "left",
	   menuDisabled : true
	  }, {
	   header : "电话",
	   dataIndex : "phone",
	   width : 200,
	   align : "left",
	   menuDisabled : true
	  }
	 ]);
	 var tempData = [[100,'安利','杭州','13500000000']];
	 var tempStore = new Ext.data.Store({
	  proxy : new Ext.data.MemoryProxy(tempData),
	  reader : new Ext.data.ArrayReader({},[{
		 name : 'id'
		}, {
		 name : 'deptName'
		}, {
		 name : 'address'
		}, {
		 name : 'phone'
		}])
	 });
	 tempStore.load();

	 //store.remove(item);
    // store.removed.push(item);
    
	var grid = new Ext.grid.GridPanel({
		renderTo:Ext.getBody(),
		title:"面板标题",
		height:150,
		width:900,
		cm : tempCM,
		sm :sm,
		store:tempStore,
		autoExpandColumn:2
	});
	var i=1;
	var addButton = new Ext.Button({
		renderTo : Ext.getBody(),
		text : '添加记录',
		handler : function(){
			//Ext.Msg.alert('a',tempStore.getAt(0).get('phone'));
			
			tempData.push([100+i,'安利'+i,'杭州'+i,'1350000000'+i]);
			i++;
			tempStore.reload();
		}
	});
	var delButton = new Ext.Button({
		renderTo : Ext.getBody(),
		text : '删除记录',
		handler : function(){
			var sm = grid.getSelectionModel();
			if(sm.getCount()==0){
				Ext.Msg.alert('提示','请选择记录');
				return;
			}
			var t = sm.getSelected();
			//Ext.Msg.alert('a',t.data.phone);//Record记录
			alert(tempStore.indexOf(t));
			tempStore.remove(t);
			tempStore.removed.push(t);
			tempStore.reload();
		}
	});
	var allRecord= new Ext.Button({
		renderTo : Ext.getBody(),
		text : '所有记录',
		handler : function(){
			tempData.push([101,'安利2','杭州2','13500000000']);
			tempStore.reload();
		}
	});
}) */

/*Ext.onReady(function(){
	var form = new Ext.form.FormPanel({
		renderTo : Ext.getBody(),
		title : '表单',
		width : 400,
		height : 300,
		items :[{
			xtype : 'combo',
			fieldLabel  : '下拉框',
			store : new Ext.data.Store({
				autoLoad : true,
				proxy : new Ext.data.MemoryProxy([
					[3,'a'],[4,'b'],[5,'c']
				]),
				reader : new Ext.data.ArrayReader({},[
					{name:'value',mapping : 0},{name:'text',mapping:1}
				])
			}),
			/*name:'xialia',*/
			/*hiddenName:'xialia',
			valueField:'text',
			displayField:'value',
			mode:'local',
			triggerAction:'all',
			emptyText:'请选择一个值'
		}],
		buttons:[
			{
				text:'本地读取',
				handler:function(){
					form.getForm.setValues({xialia:'b'});
					/*var reader = new Ext.data.JsonReader({},[
						{name:'xialia',mapping:'xialia',type:'string'}
					]);
					form.getForm.reader = reader;
					form.load({url:'./aa.txt'});//
				}
			}
		]
	});*/

	//create 2 store
var localStore = new Ext.data.SimpleStore({
    fields:["value","text"],
    data:[[1,'tom'],[2,'jarry'],[3,'rose'],[4,'mary']]
});
var remoteStore = new Ext.data.Store({			
    url:'data.aspx',
    reader:new Ext.data.JsonReader({
        root:'data',
        id:'ID'
    },[
        {name:'value',mapping:'ID'},						
        {name:'text',mapping:'Name'}
    ])
});


//create form with 2 combobox
var form = new Ext.FormPanel({
    title:'test',
    width:400,
    height:200,
    bodyStyle:'padding:5px',
    frame:true,
    labelWidth: 100,
    items:[{
        fieldLabel:'Local',
        name:'localCombo',
        hiddenName:'localCombo',
        xtype:'combo',
        store:localStore,
        mode:'local',
        valueField:'value',
        displayField:'text',
        forceSelection:true,
        editable:false,
        triggerAction:'all'
    },{
        fieldLabel:'Remote',
        name:'remoteCombo',
        hiddenName:'remoteCombo',
        xtype:'combo',
        store:remoteStore,
        mode:'remote',
        valueField:'value',
        displayField:'text',
        forceSelection:true,
        editable:false,
        triggerAction:'all'
    }]
});
form.render(document.body);

//set combo value
form.getForm().setValues({
    localCombo:3, // <- show displayField correct
    remoteCombo:3 // <- show valueField unexpect
});
});
  </script>
 </head>

 <body>
  <div id="a">cc</div>
 </body>
</html>
